/**
* @file lcd_dev_st7735s_spi4_001.c
* @brief HD096003H13 init 
* @details 
* @author huangbin
* @version V1.0.0
* @date 2025-05-20
* @copyright All documents are copyrighted by Shenzhen Xinlongwei Technology Co., LTD.
*            They may not be used for commercial purposes without permission
*/
/*******************************************************************************
HD096003H13: ST7735s,160x80,HSD玻璃
********************************************************************************/  
#include "inc.h"
#include "drv_lcd.h"

#define ROTATION_90

#ifdef ROTATION_90
    #define GRAM_OFFSET_X  0
    #define GRAM_OFFSET_Y  0x18
#else
    #define GRAM_OFFSET_X  0x18
    #define GRAM_OFFSET_Y  0
#endif
static void lcdControlerInit(DRVLCD *pLcd);
void HD096003H13_spi4_001_init(DRVLCD *pLcd)
{
#ifdef ROTATION_90
	pLcd->x				= 160;
	pLcd->y				= 80;
#else
	pLcd->x				= 80;
	pLcd->y				= 160;
#endif
	Lcd_RegInterface_Spi4_16(pLcd,GRAM_OFFSET_X,GRAM_OFFSET_Y);
	pLcd->Reset();
	lcdControlerInit(pLcd);
    pLcd->SetWindow(0,0,160,80);
    pLcd->WriteColor(COLOR_BLACK,160*80);
    LCD_Delay(100);//等待显示屏数据更新完成,避免显示花屏
}
#define Delay(x) LCD_Delay(x)
#define WriteCom(reg)	pLcd->WriteIndexReg(reg);
#define WriteData(dat)	pLcd->WriteRegParameter(dat);
static void lcdControlerInit(DRVLCD *pLcd)
{
WriteCom( 0x11);     //Sleep out

Delay(50);

WriteCom( 0xB1);     
WriteData( 0x05);   
WriteData( 0x3A);   
WriteData( 0x3A);   

WriteCom( 0xB2);     
WriteData( 0x05);   
WriteData( 0x3A);   
WriteData( 0x3A);   

WriteCom( 0xB3);     
WriteData( 0x05);   
WriteData( 0x3A);   
WriteData( 0x3A);   
WriteData( 0x05);   
WriteData( 0x3A);   
WriteData( 0x3A);   

WriteCom( 0xB4);     //Dot inversion
WriteData( 0x03);   

WriteCom( 0xC0);     
WriteData( 0xA4);   
WriteData( 0x04);   
WriteData( 0x84);   

WriteCom( 0xC1);     
WriteData( 0xC5);   

WriteCom( 0xC2);     
WriteData( 0x0D);   
WriteData( 0x00);   

WriteCom( 0xC3);     
WriteData( 0x8D);   
WriteData( 0x2A);   

WriteCom( 0xC4);     
WriteData( 0x8D);   
WriteData( 0xEE);   

WriteCom( 0xC5);     //VCOM
WriteData( 0x09);   

#ifdef ROTATION_90
    WriteCom( 0x36);     
    WriteData( 0xa8);  
#else
    WriteCom( 0x36);     
    WriteData( 0xC8);  
#endif
WriteCom( 0xE0);     
WriteData( 0x17);   
WriteData( 0x1F);   
WriteData( 0x04);   
WriteData( 0x07);   
WriteData( 0x14);   
WriteData( 0x11);   
WriteData( 0x0E);   
WriteData( 0x17);   
WriteData( 0x1D);   
WriteData( 0x25);   
WriteData( 0x36);   
WriteData( 0x3F);   
WriteData( 0x10);   
WriteData( 0x15);   
WriteData( 0x02);   
WriteData( 0x00);   

WriteCom( 0xE1);     
WriteData( 0x15);   
WriteData( 0x1C);   
WriteData( 0x05);   
WriteData( 0x04);   
WriteData( 0x11);   
WriteData( 0x0F);   
WriteData( 0x0C);   
WriteData( 0x15);   
WriteData( 0x1B);   
WriteData( 0x22);   
WriteData( 0x2F);   
WriteData( 0x3F);   
WriteData( 0x10);   
WriteData( 0x12);   
WriteData( 0x00);   
WriteData( 0x00);   

WriteCom( 0x3A);     //65k mode
WriteData( 0x05);   

WriteCom( 0x29);     //Display on
}
/************************END OF FILE*************************************/


